package com.zte.claa.inficombo.csa.app.service.persistent;

import java.util.List;
import java.util.Map;

import com.alibaba.druid.pool.DruidDataSource;
import com.zte.claa.inficombo.csa.app.model.dev.ClaaDevInitState;
import com.zte.claa.inficombo.csa.app.model.dev.DevJoinState;
import com.zte.claa.inficombo.csa.app.model.dev.DevRunState;
import com.zte.claa.inficombo.csa.app.model.redis.DevMeteData;
import com.zte.claa.inficombo.csa.app.model.version.DevVersionUpdateLog;

public interface CSADataPersistService {
	
	// devjoin消息持久化.
	public int updateDevJoinState(DevJoinState state) throws Exception;
	
	// devjoin消息持久化.
	public int updateDevRunState(DevRunState state, boolean forceUpdateDB) throws Exception;
	
	// 保存metedata数据。
	public void saveDevMeteData(DevMeteData meteData, String tabName) throws Exception;
	
	// 保存metedata数据。
	public void saveAicDevMeteData(DevMeteData meteData, String tabName, String photoid) throws Exception;
	
	// 更新metedata数据。
	public void updateAicDevMeteData(DevMeteData meteData, String tabName, String photoid) throws Exception;
	
	// 批量保存metedata数据。
	public void saveDevMeteDataByBatch(List<DevMeteData> meteDatas, String tabName) throws Exception;
	
	// 查询deveui查询最近上报的数据metedata
	public Map<String, Object> queryDevLatestMeteDataAsMap(String devEui) throws Exception; 
	
	// 保存定位原始数据.
	public void saveLocRawData(DevMeteData meteData, String tabName) throws Exception;
	
	// 批量保存定位原始数据.
	public void saveLocRawDataByBatch(List<DevMeteData> meteDatas, String tabName) throws Exception;
	
	// 保存claa自研产品的初始化状态及版本信息
	public int saveClaaDevInitState(ClaaDevInitState state) throws Exception;
	
	// 修改DevVersionUpdateLog. csa侧不需要设置taskid，更新脚本自动筛选当前最新升级任务进行匹配更新.
	public int modifyDevVersionUpdateLog(DevVersionUpdateLog log) throws Exception;
	
	// 获取project的metedb数据库的datasource
	public DruidDataSource getDataSource(String projectId) throws Exception;
	
	//使项目数据源失效
  	public void invalidDataSource(String projectId);
  	
  	// metedata缓存访问和更新接口.
  	public void putMeteDataToCache(DevMeteData data);
  	public void removeMeteDataFromCache(String devEui);
  	public DevMeteData getMeteDataFromCache(String devEui);
}
